home *** CD-ROM | disk | FTP | other *** search
- // inettest.cpp
- #include <stdio.h>
- #include <windows.h>
- #include <wininet.h>
-
- #pragma comment(lib, "wininet.lib")
-
- int main(int argc, char* argv[])
- {
- HINTERNET hInternet = InternetOpen("Agent", 0, NULL, NULL, 0);
- HINTERNET hFile = InternetOpenUrl(hInternet, argv[1], NULL, NULL, 0, 0);
- if (hFile == NULL)
- {
- fprintf(stderr, "file not found: %s", argv[1]);
- InternetCloseHandle(hInternet);
- return 1;
- }
-
- char c;
- DWORD dwBytesToRead;
- for (;;)
- {
- if (!InternetReadFile(hFile, &c, 1, &dwBytesToRead))
- break;
- if (dwBytesToRead != 1)
- break;
- putchar(c);
- }
- InternetCloseHandle(hFile);
- InternetCloseHandle(hInternet);
- return 0;
- }
-
-